import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { Card, CardFrame, CardImage } from '../AshFramework/Datas/GameConstant';
import { BundleManager } from '../AshFramework/Managers/BundleManager';
const { ccclass, property } = _decorator;

@ccclass('CardShow')
export class CardShow extends Component {

    @property(Sprite)
    FrameSprite: Sprite = null;

    @property(Sprite)
    ImageSprite: Sprite = null;

    @property(Label)
    GradeLabel: Label = null;

    NeedLabel: Label = null;

    initCard(card: Card) {
        let frameSF: SpriteFrame = BundleManager.AssetMap.get(CardFrame[card.type]) as SpriteFrame;
        if (!frameSF) {
            console.error(`在分包内找不到${CardFrame[card.type]}资源！`);
        }
        this.FrameSprite.spriteFrame = frameSF;

        let imageSF: SpriteFrame = BundleManager.AssetMap.get(CardImage[card.type][card.number]) as SpriteFrame;
        if (!imageSF) {
            console.error(`在分包内找不到${CardImage[card.type][card.number]}资源！`);
        }
        this.ImageSprite.spriteFrame = imageSF;
        this.GradeLabel.string = String(card.grade);
    }


}


